using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Mapping
{
	public class Tb_FileMap : EntityTypeConfiguration<Tb_File>
	{
		public Tb_FileMap()
		{
			// Primary Key
			this.HasKey(t => t.id);

			// Properties
			this.Property(t => t.title)
				.HasMaxLength(50);
				
			this.Property(t => t.filename)
				.HasMaxLength(50);
				
			this.Property(t => t.filetype)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("Tb_File");
			this.Property(t => t.id).HasColumnName("id");
			this.Property(t => t.title).HasColumnName("title");
			this.Property(t => t.filename).HasColumnName("filename");
			this.Property(t => t.filetype).HasColumnName("filetype");
			this.Property(t => t.count).HasColumnName("count");
			this.Property(t => t.id_new).HasColumnName("id_new");

			// Relationships
			this.HasRequired(t => t.Tb_News)
				.WithMany(t => t.Tb_File)
				.HasForeignKey(d => d.id_new);
				
		}
	}
}

